04. Building a Trading Program Using Python

PRDTM2-787 AI Trading C4 L3 Vid4 Building A Trading Program Using Python

Building an Algorithmic Trading Program

This guide focuses on the initial steps to develop a trading algorithm program, emphasizing essential packages and database setup.

Key Steps and Packages:

  • Importing Packages:
    • Numpy: For numerical calculations.
    • Scipy.stats.norm: For normal distribution calculations.
    • CSV Module: Handles CSV file operations.
    • Contextlib.closing: Manages resources like database connections.
    • SQLite3: Used for a lightweight local database setup.

Database Management:

  • SQLite3 Benefits:
    • Local database reduces server workload and network traffic.
    • Doesn't have a server running in the background, stores data in a single file.
    • Quiet performance boost even on the same computer.

Setup Process:

  • Global Variables:

    • Conn: Connection to SQLite3 database stored in SP 500.db.
    • CS: Cursor for database connection.
  • Resource Management:

    • Utilize with closing to ensure resources are released.

Functions Overview:

  • Prepare: Sets up the initial database.
  • Main: Core loop for the trading algorithm.

Further detailed components and functions will be covered later.